﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Domain.Rules
{
    /// <summary>
    /// 规则基础
    /// </summary>
    [Serializable]
    public class RuleBase : IRule
    {
        private string fieldName;
        private object holder;

        public RuleBase(int ruleId, string[] participatingLogicalFields, string fieldName, object holder)
        {
            // TODO: Complete member initialization
            this.RuleId = ruleId;
            this.ParticipatingLogicalFields = participatingLogicalFields;
            this.fieldName = fieldName;
            this.holder = holder;
        }
        public virtual bool IsValid
        {
            get;
            private set;
        }

        public int RuleId
        {
            get;
            private set;
        }

        public string[] ParticipatingLogicalFields
        {
            get;
            private set;
        }

        public object GetValue()
        {
            throw new NotImplementedException();
        }

        public static void CollectBrokenRules(IList<IRule> brokenRules, IList<IRule> rulesToCheck)
        {
            foreach (IRule r in rulesToCheck)
            {
                if (!r.IsValid)
                    brokenRules.Add(r);
            }
        }
    }
}
